<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>整数反转</title>
</head>

<body>
	<input type="text" placeholder="输入整数" id="num">
	<div id="text">此处展示反转后数字</div>
	<script>
		let txt = document.querySelector('#text')
		let num = document.querySelector('#num');
		num.addEventListener('keyup', () => {
			let _num = num.value.split('-').reverse()[0].split('').reverse().join('') * (num.value < 0 ? -1 : 1)
			txt.innerHTML = _num
		})
	</script>
</body>

</html>